package run.siyuan.jdk.测试;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.cron.pattern.CronPatternUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import org.junit.jupiter.api.Test;
import org.springframework.scheduling.support.CronExpression;
import org.springframework.scheduling.support.CronSequenceGenerator;

import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @className: GitTest
 * @Description: TODO
 * @author: siyuan
 * @date: 2022/4/2 4:09 PM
 */
public class GitTest {

    @Test
    public void test1(){
//        DateTime dateTime = DateUtil.parseDateTime("2022-07-22 03:10:00");
//        System.out.println(dateTime.getField(DateField.MINUTE));

        String s = "[{\"url\":\"https://imehome.oss-cn-hangzhou.aliyuncs.com/products/2019/5/4/1131489884285042688.jpg\",\"type\":\"image\"},{\"url\":\"https://imehome.oss-cn-hangzhou.aliyuncs.com/products/2019/5/4/1131489928199405568.jpg\",\"type\":\"image\"},{\"url\":\"https://imehome.oss-cn-hangzhou.aliyuncs.com/products/2019/5/4/1131489979080507392.jpg\",\"type\":\"image\"}]";
        JSONArray jsonArray = JSONUtil.parseArray(s);
        JSONObject jsonObject = JSONUtil.parseObj(jsonArray.get(0));
        System.out.println(jsonObject.getStr("url"));
        System.out.println(jsonObject.set("url", "https://imehome.oss-cn-hangzhou.aliyuncs.com/image/WechatIMG8397.jpeg"));


    }

    /**
     * test2
     */
    @Test
    public void test2() {
//        DateTime time = DateUtil.parseDate(DateUtil.format(DateUtil.date(), "yyyy-MM-dd 00:00:00"));
//        System.out.println(time);
//        DateTime dateTime = DateUtil.offsetDay(time, -2);
//        System.out.println(dateTime.getTime());
//        DateTime a = DateUtil.offsetDay(DateUtil.date(), -2);
//        System.out.println(a.getTime());
//        System.out.println(DateUtil.offsetDay(DateUtil.parseDate(DateUtil.format(DateUtil.date(), "yyyy-MM-dd 00:00:00")), -2).getTime());
        Date date = DateUtil.parseDateTime("2022-07-22 01:00:30");
        CronSequenceGenerator generator = new CronSequenceGenerator("0 0/10 0-1,3-23 * * ?");
        for (int i = 0; i < 200; i++) {
            date = generator.next(date);
            System.out.println(DateUtil.formatDateTime(date));

        }
    }

}
